<template>
  <div class="localtransportation">
    <div class="toplist">
      <div class="topitem" v-for="(item, index) in dataList" :key="index">
        <div class="topname">{{ item.xmlb }}</div>
        <div class="topnum">
          <b>{{ item.sl }}</b
          >{{ item.dw }}
        </div>
        <div class="toppercent" :class="{ greenpercent: item.zs < 0 }">
          <i></i>{{ item.zs }}%
        </div>
      </div>
    </div>
    <div class="bottom-row">
      <div class="name">{{ bottomInfor.xmlb }}</div>
      <div class="value-wrapper">
        <span>{{ bottomInfor.sl }}</span>
        <span>{{ bottomInfor.dw }}</span>
      </div>
      <div class="rate" :class="{ greenpercent: bottomInfor.zs < 0 }">
        {{ bottomInfor.zs }}%
      </div>
    </div>
  </div>
</template>

<script>
import { getAction } from '@/api/manage.js'

export default {
  data() {
    return {
      dataList: [],
      bottomInfor: {}
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    getData() {
      getAction('/topic/data/listAllBySql/dy_app_xxzb_dfjtys').then((res) => {
        this.dataList = []
        if (res.result && res.result.length > 0) {
          res.result.forEach((element) => {
            if (element.xmlb.indexOf('航空货邮吞吐量') > -1) {
              this.bottomInfor = element
            } else {
              this.dataList.push(element)
            }
          })
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.localtransportation {
  width: 100%;
  height: 100%;
  .toplist {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    .topitem {
      width: 32%;
      height: 90px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      background: url("../images/localTransportation_bg.png") no-repeat center;
      background-size: 100% 100%;
      margin-bottom: 10px;
      .topname {
        width: 100%;
        text-align: center;
        font-family: MicrosoftYaHeiUI;
        font-size: 16px;
        color: #ffffff;
      }
      .toppercent {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
        font-weight: bold;
        font-size: 14px;
        color: #ff3e3e;
        position: relative;
        i {
          width: 8px;
          height: 12px;
          background: url("../images/up-arrow.png") no-repeat;
          background-size: 100% 100%;
        }
        &.greenpercent {
          color: #18c624;
          i {
            width: 8px;
            height: 12px;
            background: url("../images/down-arrow.png") no-repeat;
            background-size: 100% 100%;
          }
        }
      }
      .topnum {
        width: 100%;
        height: 21px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: url("../images/text-bg2.png") no-repeat center;
        background-size: 100% 100%;
        font-family: MicrosoftYaHeiUI;
        font-size: 12px;
        color: #ffffff;
        margin-top: 5px;
        margin-bottom: 5px;
        b {
          font-family: YouSheBiaoTiHei;
          font-size: 24px;
          color: #16fdf5;
        }
      }
    }
  }
  .bottom-row {
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 49px;
    background: url("../images/l-row-bg.png") no-repeat;
    background-size: 100% 100%;

    .name {
      font-family: MicrosoftYaHeiUI;
      font-size: 16px;
      color: #ffffff;
    }
    .value-wrapper {
      display: flex;
      align-items: center;

      span:first-child {
        margin-right: 4px;
        font-family: YouSheBiaoTiHei;
        font-size: 24px;
        color: #ffde00;
        line-height: 1.5;
      }
      span:last-child {
        font-family: MicrosoftYaHeiUI;
        font-size: 14px;
        color: #ffffff;
      }
    }
    .rate {
      display: flex;
      align-items: center;
      font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
      font-weight: bold;
      font-size: 16px;
      color: #ff3e3e;

      &::before {
        margin-right: 4px;
        display: block;
        width: 10px;
        height: 14px;
        background: url("../images/up-arrow.png") no-repeat;
        background-size: 100% 100%;
        content: "";
      }
      &.greenpercent {
        color: #18c624;
        &::before {
          margin-right: 4px;
          display: block;
          width: 10px;
          height: 14px;
          background: url("../images/down-arrow.png") no-repeat;
          background-size: 100% 100%;
          content: "";
        }
      }
    }
  }
}
</style>
